package com.caipiao.crawler.run;

import com.caipiao.constant.CrawlerConstants;
import com.caipiao.crawler.daletou.DaletouResultPage;
import com.caipiao.crawler.daletou.DaletouResultPipeline;
import com.caipiao.crawler.qixingcai.QixingcaiResultPage;
import com.caipiao.crawler.qixingcai.QixingcaiResultPipeline;
import us.codecraft.webmagic.Spider;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by adminitrator on 2018/7/28.
 */
public class Qixingcai implements RunCrawler {

    @Override
    public void run() {
        Spider.create(new QixingcaiResultPage())
                .addUrl(CrawlerConstants.QIXINGCAI_HISTORY_URL)
                .addPipeline(new QixingcaiResultPipeline())
                .thread(4)
                .run();
    }

    @Override
    public void runHistory() {
        List<String> urls = new ArrayList<String>();
        for (int i = 18058; i < 18088; i++) {
            urls.add(CrawlerConstants.QIXINGCAI_DATA_URL + i);
        }
        Spider.create(new QixingcaiResultPage())
                .addUrl(urls.toArray(new String[0]))
                .addPipeline(new QixingcaiResultPipeline())
                .thread(10)
                .run();
    }
}
